package _7jvm;

/**
 * @description:
 * @author: wang zhen
 * @create: 2022-06-30 09:47
 */
public class StrTest2 {

    public static void main(String[] args){

        long start = System.currentTimeMillis();
        sbAdd();
        long end = System.currentTimeMillis();

        System.out.println(end-start);//6787
    }

    public static void strAdd(){
        String str = "";
        for(int i=0;i<100000;i++){
            str+="a";
        }
    }

    public static void sbAdd(){
        String str = "";
        StringBuilder sb=new StringBuilder(100000);
        for(int i=0;i<100000;i++){
            sb.append("a");
        }

        str=sb.toString();
    }
}
